package experiment3;

import java.util.Scanner;

public class No_7 {
    public static void main(String []args)
    {
        double[][] matrix=new double[3][4];
        Scanner input=new Scanner(System.in);

        System.out.println("请输入一个4X3的矩阵：");

        for (int i=0;i<3;i++)
        {
            for (int j=0;j<4;j++)
            {
                matrix[i][j]=input.nextDouble();
            }
        }

        for (int i=0;i<4;i++)
        {
            System.out.println("第 "+i+" 列元素的和为 "+sumColumn(matrix,i));
        }

    }


    public static double sumColumn (double[][] m , int columnlndex)
    {
        double sum=0;
        for (int i=0;i<3;i++)
        {
            sum=sum+m[i][columnlndex];
        }
        return sum;
    }

}
